﻿using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 自定义配置提供者
{
    internal class TestWebConfig
    {
        private IOptionsSnapshot<WebConfig> optWebConfig;
        public TestWebConfig(IOptionsSnapshot<WebConfig> optWebConfig)
        {
            this.optWebConfig = optWebConfig;
        }

        public void Test()
        {
            var webConfig = this.optWebConfig.Value;
            Console.WriteLine($"webConfig.Conn1.ConnectionString:\t{webConfig.Conn1.ConnectionString}");
            Console.WriteLine(webConfig.Conn1.ProviderName);
            Console.WriteLine($"webConfig.Conn2.ConnectionString:\t{webConfig.Conn2.ConnectionString}");
            Console.WriteLine(webConfig.Conn2.ProviderName);
            Console.WriteLine(webConfig.Config.Name);
            Console.WriteLine(webConfig.Config.Age);
            Console.WriteLine(webConfig.Config.Proxy.Ip);
            Console.WriteLine(webConfig.Config.Proxy.Port);
            Console.WriteLine(webConfig.Config.Proxy.ids[0]);
            Console.WriteLine(webConfig.Config.Proxy.ids[1]);
            Console.WriteLine(webConfig.Config.Proxy.ids[2]);
        }
    }
}
